home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 018 / pcfil_wp.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1984-04-24  |  6.0 KB  |  117 lines

  1. 100  ' ***************************************************
  2. 101  ' *  PC-FILE III to WORDPERFECT Conversion Program  *
  3. 102  ' *                                                 *
  4. 103  ' *  (c)1984 by Read Gilgen   All Rights Reserved   *
  5. 104  ' *                                                 *
  6. 105  ' *  A limited license is hereby granted to copy,   *
  7. 106  ' *  and otherwise distribute this program, with    *
  8. 107  ' *  the provision that this copyright notice is    *
  9. 108  ' *  neither changed nor bypassed, and that no      *
  10. 109  ' *  commercial gain is made.                       *
  11. 110  ' ***************************************************
  12. 120  CLS:KEY OFF
  13. 125  LOCATE 13,27:PRINT "PC-FILE III to WORDPERFECT"
  14. 130  LOCATE 15,26:PRINT "Data File Conversion Program"
  15. 135  LOCATE 19,29:PRINT "(c)1984 by Read Gilgen"
  16. 140  LOCATE 25,1:PRINT "Press any key to continue . . .";
  17. 145  ANS$=INPUT$(1):CLS
  18. 150   PRINT TAB(27) "PC-FILE III to WORDPERFECT"
  19. 155   PRINT TAB(26) "Data File Conversion Program"
  20. 160  PRINT:PRINT
  21. 165  PRINT "  This program allows you to convert any PC-FILE data file into the required"
  22. 170  PRINT "format for use by WordPerfect's MERGE program."
  23. 175  PRINT:PRINT "  Before beginning, you should be sure that both the xxxxx.DTA and the"
  24. 180  PRINT "xxxxx.HDR files are in any drive, and that there is sufficient disk space"
  25. 185  PRINT "to receive the resulting xxxxx.WP file.
  26. 190  PRINT:PRINT "  Also, you must have booted BASIC (or compiled the program) using "
  27. 195  PRINT "the /S:xxxx option, allowing for total bytes per record."
  28. 200  PRINT:PRINT "  You may wish to sort and selectively `clone' the PC-FILE data before using"
  29. 205  PRINT "this conversion program, although if you have WordPerfect's SORT program, you"
  30. 210  PRINT "can sort and select after the conversion."
  31. 215  PRINT:PRINT "  If you have a large database or intend to convert often, it would be wise"
  32. 220  PRINT "to compile this program first."
  33. 225  LOCATE 25,1:PRINT "Press any key to continue . . .";
  34. 230  ANS$=INPUT$(1)
  35. 1000  '               Get the filename and drive specifications
  36. 1010  KEY OFF:CLS
  37. 1020  DIM HDR$(200),FLD(2000),FLD$(2000)
  38. 1030  ON ERROR GOTO 10000
  39. 1040  PRINT "What is the name of the file to be converted (No extensions)";
  40. 1050  INPUT FIL$
  41. 1060  Y$=".":X=INSTR(FIL$,Y$):IF X>0 THEN FIL$=LEFT$(FIL$,X-1)
  42. 1070  IF LEN(FIL$)>8 THEN FIL$="":PRINT "Maximum 8 characters in filename";:            GOTO 1050
  43. 1080  INPUT "Which drive has the data (No colon)";INDRV$
  44. 1090  IF INDRV$="" THEN GOTO 1080
  45. 1100  INPUT "Which drive for the output file (No colon)";OUTDRV$
  46. 1110  IF OUTDRV$="" THEN GOTO 1100
  47. 1120  INFILE1$=LEFT$(INDRV$,1)+":"+FIL$+".HDR"
  48. 1130  INFILE2$=LEFT$(INDRV$,1)+":"+FIL$+".DTA"
  49. 1140  OUTFILE$=LEFT$(OUTDRV$,1)+":"+FIL$+".WP
  50. 1150  '              Get field and record length information
  51. 1160  OPEN "I",1,INFILE1$
  52. 1170  WHILE NOT EOF(1)
  53. 1180  CTR=CTR+1
  54. 1190    LINE INPUT #1,HDR$(CTR)
  55. 1200    INPUT #1,FLD(CTR)
  56. 1210    IF TOTFLD(PASS)+FLD(CTR)>256 THEN PASS=PASS+1
  57. 1220    TOTFLD(PASS)=TOTFLD(PASS)+FLD(CTR)
  58. 1230  WEND
  59. 1240  CLOSE
  60. 1250  CLS:PRINT "For your information, the following fields and lengths"
  61. 1260  PRINT "apply to each record in the ";CHR$(34);FIL$;CHR$(34);" database."
  62. 1270  PRINT
  63. 1280  FOR LOOP = 1 TO CTR
  64. 1290  IF LOOP>20 THEN LOCATE (LOOP-17),40
  65. 1300  PRINT LOOP;"  ";HDR$(LOOP);" =";FLD(LOOP)
  66. 1310  NEXT
  67. 1320  LOCATE 25,1:PRINT "Press any key to continue . . .";
  68. 1330  ANS$=INPUT$(1):CLS
  69. 1340  FOR TOTAL=0 TO PASS:TOTFLDS=TOTFLDS+TOTFLD(TOTAL):NEXT
  70. 1350  IF TOTFLDS>128 THEN PRINT "The total length of each record is";TOTFLDS;"  Make sure you have booted":PRINT "BASIC using the /S: option.":LOCATE 25,1:PRINT "Press any key to continue . . .";:ANS$=INPUT$(1):CLS
  71. 2000  '                Read the Data from PC-FILE
  72. 2010  OPEN "R",1,INFILE2$,TOTFLDS+1
  73. 2020  FIELD 1,TOTFLD(0) AS INFO$(0),TOTFLD(1) AS INFO$(1),TOTFLD(2) AS INFO$(2),        TOTFLD(3) AS INFO$(3)
  74. 2030  '                Prepare File for Output (Data is Appended)
  75. 2040  OPEN "A",2,OUTFILE$
  76. 2050  RCDS = INT(LOF(1)/TOTFLDS)
  77. 2060  FOR LOOP = 1 TO RCDS
  78. 2070  PLC=1:PASS=0
  79. 2080  GET #1,LOOP
  80. 2090  FOR SPLIT= 1 TO CTR
  81. 2100    IF PLC+FLD(SPLIT)>256 THEN PLC=1:PASS=PASS+1
  82. 2110      FLD$(SPLIT)=MID$(INFO$(PASS),PLC,FLD(SPLIT))
  83. 2120    PLC=PLC+FLD(SPLIT)
  84. 2130  NEXT
  85. 2140  IF LEFT$(INFO$(0),1)="\" THEN GOTO 2170
  86. 2150  GOSUB 2180
  87. 2160  NEXT
  88. 2170  CLS:PRINT "Conversion of the ";CHR$(34);FIL$;CHR$(34);" database to ";CHR$(34);FIL$;".WP";CHR$(34);" is now completed."
  89. 2171  PRINT
  90. 2172  PRINT "NOTE: The ";FIL$;".WP file is a DOS file and has miscellaneous"
  91. 2173  PRINT "    characters at the end. Retrieve this file using WordPerfect's"
  92. 2174  PRINT "    ALT-F1 (Extended Features) as a DOS (ASCII) file and then"
  93. 2175  PRINT "    re-save it as you normally do.  The file will then be ready"
  94. 2176  PRINT "    to use with WordPerfect's merge program."
  95. 2178  LOCATE 23,1:END
  96. 2180  '               Print Record to Output File
  97. 2190  FOR PRINTOUT=1 TO CTR
  98. 2200    FOR STRIP=LEN(FLD$(PRINTOUT)) TO 1 STEP -1
  99. 2210      IF MID$(FLD$(PRINTOUT),STRIP,1)<>" " THEN 2230                                    ELSE FLD$(PRINTOUT)=LEFT$(FLD$(PRINTOUT),(LEN(FLD$(PRINTOUT))-1))
  100. 2220    NEXT STRIP
  101. 2230      PRINT FLD$(PRINTOUT)
  102. 2240      PRINT #2,FLD$(PRINTOUT)+CHR$(18)+CHR$(10); 'Field marker, WordPerfect
  103. 2250  NEXT PRINTOUT
  104. 2260  PRINT #2,CHR$(5)+CHR$(10);   'End of record marker for WordPerfect
  105. 2270  RETURN
  106. 10000  '                Error Trapping Routines
  107. 10010  PRINT:PRINT:PRINT
  108. 10020  IF ERR=50 THEN PRINT "A field overflow has occurred.  You must reboot BASIC using the":PRINT "/s: option to allocate bytes for record lengths in excess":PRINT "of 128 bytes.":PRINT "Press any key to return to DOS.":ANS$=INPUT$(1):SYSTEM
  109. 10030  IF ERR=53 AND ERL=1160 THEN PRINT "The file ";INFILE1$;" was not found.":PRINT "Do you wish to revise the (D)rive, (F)ilename, or mount the proper disk and (R)esume? (D,F,R)":ANS$=INPUT$(1):ELSE GOTO 10060
  110. 10040  IF ANS$="D" OR ANS$="d" THEN CLS:RESUME 1080:ELSE IF ANS$="F" OR ANS$="f" THEN CLS:RESUME 1040:ELSE IF ANS$="R" OR ANS$="r" THEN RESUME:ELSE GOTO 10030
  111. 10050  IF ERR=53 AND ERL=2010 THEN PRINT "The file ";INFILE2$;" was not found.":PRINT "Do you wish to revise the (D)rive, (F)ilename, or mount the proper disk and (R)esume? (D,F,R)":ANS$=INPUT$(1):GOTO 10040
  112. 10060  IF ERR=61 THEN PRINT "Insufficient disk space.  Please correct and then . . .":PRINT "     Press any key to resume.":ANS$=INPUT$(1):RESUME
  113. 10070  IF ERR=70 THEN PRINT "Disk is write-protected.  Please correct and then . . .":PRINT "     Press any key to resume.":ANS$=INPUT$(1):RESUME
  114. 10080  IF ERR=71 THEN PRINT "Disk is not ready (door open?).  Please correct and then . . .":PRINT "     Press any key to resume.":ANS$=INPUT$(1):RESUME
  115. 10090  IF ERR=64 THEN CLS:PRINT "You have used an improper filename.":PRINT:RESUME 1040
  116. 10100  PRINT "Error #";ERR;" has occurred in line";ERL:PRINT " Please refer to the BASIC manual and correct before running the program":PRINT:PRINT"Press any key to return to DOS.":ANS$=INPUT$(1):SYSTEM
  117.